package com.zhang.boot.core.exception;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.zhang.boot.core.constants.ErrorEnum;
import lombok.Data;

@Data
public class BusinessException extends RuntimeException {
    private int code;
    private String message;

    @JsonIgnore
    private ErrorEnum errorEnum;

    public BusinessException(ErrorEnum errorEnum) {
        this.code = errorEnum.getCode();
        this.message = errorEnum.getMessage();
        this.errorEnum = errorEnum;
    }

    public BusinessException(ErrorEnum errorEnum, String message) {
        this.code = errorEnum.getCode();
        this.message = message;
        this.errorEnum = errorEnum;
    }
}
